@extends('layouts.application')

@section('content')
    <div class="admin-content">
        <div class="admin-content-body">
            <div class="am-cf am-padding am-padding-bottom-0">
                <div class="am-fl am-cf"><strong class="am-text-primary am-text-lg">新增广告</strong> /
                    <small>Create A New Ad</small>
                </div>
            </div>

            <hr>

            <div class="am-u-sm-12 am-u-md-8">
                <form class="am-form am-form-horizontal" action="{{route('ad.advert.store')}}" method="post">

                    {{ csrf_field() }}
                    @include('layouts.shared._flash')

                    <div class="am-form-group">
                        <label class="am-u-sm-2 am-form-label">所属分类</label>
                        <div class="am-u-sm-10">
                            <select name="category_id"
                                    data-am-selected="{btnWidth: '100%',  btnStyle: 'secondary', btnSize: 'sm', maxHeight: 260, searchBox: 1}">

                                <option value="0">选择分类</option>
                                @foreach($categories as $category)
                                    <option value="{{$category->id}}">{{$category->name}}</option>
                                @endforeach

                            </select>
                        </div>
                    </div>

                    <div class="am-form-group">
                        <label class="am-u-sm-2 am-form-label">标题</label>
                        <div class="am-u-sm-10">
                            <input type="text" name="title">
                        </div>
                    </div>

                    <div class="am-form-group">
                        <label class="am-u-sm-2 am-form-label">网址</label>
                        <div class="am-u-sm-10">
                            <input type="text" name="url">
                        </div>
                    </div>

                    <div class="am-form-group">
                        <label class="am-u-sm-2 am-form-label">缩略图</label>
                        <div class="am-u-sm-10">
                            <div class="am-form-group am-form-file">
                                <button type="button" class="am-btn am-btn-success am-btn-sm">
                                    <i class="am-icon-cloud-upload" id="loading"></i> 上传新的缩略图
                                </button>
                                <input type="file" id="image_upload">
                                <input type="hidden" name="thumb">
                            </div>
                            <div>
                                <img src="" id="img_show" style="max-height: 200px;">
                            </div>
                        </div>
                    </div>

                    <hr>

                    <div class="am-form-group">
                        <label class="am-u-sm-2 am-form-label">广告描述</label>
                        <div class="am-u-sm-10">
                            <textarea class="" rows="5" name="description"></textarea>
                        </div>
                    </div>

                    <div class="am-form-group">
                        <label class="am-u-sm-2 am-form-label">排序</label>
                        <div class="am-u-sm-10">
                            <input type="text" name="sort_order">
                        </div>
                    </div>

                    <div class="am-form-group">
                        <label class="am-u-sm-2 am-form-label">是否显示</label>
                        <div class="am-u-sm-10">
                            <label class="am-radio-inline">
                                <input type="radio" value="1" name="is_show"> 是
                            </label>
                            <label class="am-radio-inline">
                                <input type="radio" value="0" name="is_show"> 否
                            </label>
                        </div>
                    </div>

                    <div class="am-form-group">
                        <div class="am-u-sm-10 am-u-sm-offset-2">
                            <button type="submit" class="am-btn am-btn-primary">提 交</button>
                        </div>
                    </div>
                </form>
            </div>

        </div>

    </div>
@endsection

@section('js')
    <script src="/vendor/html5-fileupload/jquery.html5-fileupload.js"></script>
    <script src="/js/upload.js"></script>
@endsection
